home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_11_1986_Transactor_Publishing.d64
/
screenboard src
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2023-02-26
|
7KB
|
381 lines
100 sys700
110 ; "screenboard"
120 ; joystick-controlled on-screen
130 ; keyboard
140 ;
150 ;original program by david tomblin
160 ; this version jan86 -cz
170 ;
180 ; from
190 ; "[212]he [212]ransactor"
200 ;
210 ;
220 .opt oo
230 *=$c000
240 ;
250 chrout =$ffd2
260 plot =$fff0
270 screen =$fb
280 joymask =$fd
290 temp =$fe
300 temp2 =$ff
310 xadd =$8b
320 joy =56320
330 ;
340 jmp start
350 ;
360 colour .byte 14 ;screenboard colour
370 sindex .byte 0 ;screen index
380 rvschar .byte 0
390 movflg .byte 0
400 keyflags =*
410 .byte 0 ;shift off/on/lock
420 .byte 0 ;ctrl off/on/lock
430 .byte 0 ;commdr off/on/lock
440 togcnt .byte 0
450 tog2 .byte 0
460 flagim .byte 0
470 stopflg .byte 0
480 olkvec .word 0
490 olstop .word 0
500 ;
510 start =*
520 sei
530 lda #<irqrtn ;irq vector
540 sta $0314
550 lda #>irqrtn
560 sta $0315
570 ;save keyboard vector
580 lda $028f
590 sta olkvec
600 lda $0290
610 sta olkvec+1
620 ;change the stop vector
630 lda $0328
640 sta olstop
650 lda $0329
660 sta olstop+1
670 lda #<newstop
680 sta $0328
690 lda #>newstop
700 sta $0329
710 cli
720 rts
730 ;
740 ;
750 newkbd =* ;new keyboard setup rtn
760 lda flagim ;shift/c=/ctrl
770 sta 653
780 jmp (olkvec)
790 ;
800 ;
810 newstop =*
820 lda stopflg
830 beq nostop
840 sta $91
850 lda #0
860 sta stopflg
870 nostop =*
880 jmp (olstop)
890 ;
900 ;
910 irqrtn =*
920 jsr drawscrn ;draw screenboard
930 sec
940 jsr plot ;check cursor pos
950 cpx #6 ;see if it's in scrnbrd
960 bcs crsok ;no it isn't
970 ;yes it is, move cursor down
980 ldx #6
990 clc
1000 jsr plot
1010 crsok =*
1020 jsr scmove ;scrnbd cursor move
1030 jmp $ea31
1040 rts
1050 ;
1060 ;
1070 scmove =* ;move sc cursor row, col
1080 lda joy
1090 and #31
1100 eor #31
1110 sta joymask
1120 bne scm0 ;stick moved
1130 lda #0
1140 sta movflg
1150 jmp nostor
1160 scm0 =*
1170 lda movflg ;moved last time
1180 bne nostor
1190 lda #1
1200 sta movflg
1210 lda #16 ;fire button bit
1220 bit joymask
1230 bne keypush ;enter key
1240 lda joymask
1250 and #1 ;check up
1260 beq scm1 ;not up, check down
1270 ldx #-40 ;up, subtract 40
1280 scm1 =*
1290 lda joymask
1300 and #2 ;check down
1310 beq scm2 ;not down, check left
1320 ldx #40 ;down, add 40
1330 scm2 =*
1340 lda joymask
1350 and #4 ;check left
1360 beq scm3 ;not left, check right
1370 lda sindex
1380 cmp #120
1390 bcc sub2 ;subtract 2 for top rows
1400 ldx #-4 ;subtract 4 for bottom 2
1410 jmp scm3
1420 sub2 =*
1430 ldx #-2 ;left, subtract 2
1440 scm3 =*
1450 lda joymask
1460 and #8 ;check right
1470 beq scm4 ;not right
1480 lda sindex
1490 cmp #120
1500 bcc add2
1510 ldx #4
1520 jmp scm4
1530 add2 =*
1540 ldx #2
1550 ;
1560 scm4 =*
1570 stx xadd
1580 lda sindex
1590 clc
1600 adc xadd
1610 bpl stornew ;keep sb cursor
1620 cmp #200
1630 bcs nostor ;in bounds
1640 stornew =*
1650 sta sindex
1660 sta rvschar
1670 cmp #120
1680 bcc nostor
1690 and #%11111100
1700 sta rvschar ;last 2 rows in 4s
1710 nostor =*
1720 rts
1730 ;
1740 ;
1750 keypush =* ;enter key
1760 lda sindex
1770 cmp #120 ;"top 3 rows?
1780 bcs kps1 ;no
1790 lsr a ;yes, just divide by 2
1800 jmp kps2
1810 kps1 [178][172]
1820 ;in bot[164]m 3 rows
1830 sec
1840 sbc #120
1850 lsr a
1860 lsr a
1870 clc
1880 adc #k[195]
1890 kps2 [178][172]
1900 ;
1910 tax
1920 lda keys,x ;[161] key from table
1930 cmp #249
1940 bcs special ;special character
1950 n[176]mc [178][172] ;n[176]mal character
1960 cpx #37 ;check, alphanumerics
1970 bcs kbuf ;no, use kbd buffer
1980 ;yes, use cus[164]m keyboard trap
1990 lda keycodes,x ;[161] key code
2000 sta 203 ;last key
2010 jsr [162]kbd ;[153] the character
2020 jsr kill[164]g ;kill shft[173]ctrl[173]comm
2030 rts
2040 ;
2050 kbuf [178][172]
2060 ldy 198 ;# chars in buffer
2070 cpy 649 ;max buffer size
2080 bcs kbuf1 ;buffer full
2090 lda keys,x ;[161] key from table
2100 sta 631,y ;put in kbd buffer
2110 inc 198 ;inc[143]ent buf pointer
2120 kbuf1 [178][172]
2130 jsr kill[164]g
2140 rts
2150 ;
2160 ;
2170 special [178][172] ;h[175]le special chars
2180 cmp #249 ;[144] key
2190 bne spl1
2200 lda #$7f
2210 sta [144]flg
2220 rts
2230 ;
2240 spl1 [178][172]
2250 sec
2260 sbc #250 ;must be sh[139]t[173]ctrl[173]comm
2270 lsr a
2280 tax
2290 lda #1
2300 adc #0
2310 sta temp2 ;1 [139] c set, 2 [139] [156]
2320 lda keyflags,x
2330 e[176] temp2 ;switch [145][173]off [176]
2340 [175] temp2 ; lok[173]off [164]ggle
2350 sta keyflags,x
2360 ;
2370 makimag [178][172] ;set up key image
2380 lda #0
2390 sta flagim
2400 ldx keyflags
2410 beq nk1
2420 [176]a #1
2430 nk1 [178][172]
2440 ldx keyflags[170]1
2450 beq nk2
2460 [176]a #4
2470 nk2 [178][172]
2480 ldx keyflags[170]2
2490 beq nk3
2500 [176]a #2
2510 nk3 [178][172]
2520 sta flagim
2530 rts
2540 ;
2550 ;
2560 kill[164]g [178][172] ;kill 1[171]time key flags
2570 ldx #2
2580 kil1 [178][172]
2590 lda keyflags,x
2600 [175] #2
2610 sta keyflags,x
2620 dex
2630 bpl kil1
2640 jsr makimag
2650 rts
2660 ;
2670 ;
2680 drawscrn [178][172] ;draw screenboard
2690 lda 648 ;screen page
2700 sta screen[170]1
2710 lda #0
2720 sta screen
2730 sta [164]gcnt
2740 sta [164]g2
2750 ldx #0
2760 ldy #0
2770 dr1 [178][172]
2780 lda #32
2790 sta (screen),y
2800 lda keys,x
2810 [175] #63
2820 cpy rvschar ;check [129] revers chr
2830 bne n[176]vs
2840 [176]a #128 ;set high bit [164] rvrs
2850 n[176]vs [178][172]
2860 iny
2870 sta (screen),y
2880 lda colour
2890 sta $d800,y
2900 iny
2910 inx
2920 cpx #k[195]
2930 bcc dr1
2940 ;
2950 ; [153] bot[164]m two kbd rows
2960 ldx #0 ;character counter
2970 dr2 [178][172]
2980 lda xkeys,x
2990 cmp #255 ;[164]ggles
3000 bne [168]og
3010 jsr draw[164]g ;[153] off,[145],[176] lok
3020 [168]og [178][172]
3030 [175] #63
3040 sta temp
3050 lda rvschar ;check highlight chr
3060 cmp #120
3070 bcc n[176]vs2 ;n[145]e [164] highlight
3080 tya
3090 clc
3100 sbc rvschar ;highlight
3110 cmp #3 ; three characters
3120 bcs n[176]vs2 ; [139] opti[145]
3130 lda temp ; is selected
3140 [176]a #128
3150 sta temp
3160 n[176]vs2 [178][172]
3170 lda temp
3180 sta (screen),y
3190 lda colour
3200 sta $d800,y
3210 iny
3220 inx
3230 cpx #xk[195] ;# of chars
3240 bmi dr2
3250 ;
3260 ;underline keyboard
3270 ldx #40 ;[153] 40 chars
3280 dr3 [178][172]
3290 lda #64 ;underline char
3300 sta (screen),y
3310 lda colour
3320 sta $d800,y
3330 iny
3340 dex
3350 bne dr3
3360 rts
3370 ;
3380 ;
3390 draw[164]g [178][172]
3400 ;[153] off, [145], [176] lock message
3410 txa
3420 pha
3430 ldx [164]gcnt ;0[178]shft, 1[178]ctrl, 2[178]com
3440 lda keyflags,x ;off, [145], [176] lok
3450 asl a
3460 asl a ;x4 [164] po[181] [164] [164]gtext
3470 clc
3480 adc [164]g2
3490 tax
3500 lda [164]gtext,x
3510 sta temp
3520 inc [164]g2
3530 lda [164]g2
3540 cmp #3
3550 bcc tgl
3560 inc [164]gcnt
3570 lda #0
3580 sta [164]g2
3590 tgl [178][172]
3600 pla
3610 tax
3620 lda temp
3630 rts
3640 ;
3650 ;
3660 keys [178][172]
3670 .[198] "abcdefghijklmnopqrs "
3680 .[198] "tuvwxyz0123456789[] "
3690 .byte 33,34
3700 .[198] "#$%&'(),.?:;<=>@^ "
3710 k[195] [178][172][171]keys
3720 ctrlchrs [178][172]
3730 .byte 145,17,157,29,148,20,19,147,43,45
3740 .byte 13,249,250,251,252,253,254,255
3750 .[198] "*/"
3760 ;
3770 xkeys [178][172]
3780 .[198] " cup cdn clf crt ins del hom clr + - "
3790 .[198] " rtn stp shf:(NULL)(NULL)(NULL) ctl:(NULL)(NULL)(NULL) com:(NULL)(NULL)(NULL) * / "
3800 xk[195] [178][172][171]xkeys
3810 ;
3820 [164]gtext .[198] "off on lok "
3830 ;
3840 x40 .byte 0,40,80,120,160
3850 ;
3860 keycodes [178][172]
3870 .byte 10,28,20,18,14,21,26,29,33,34
3880 .byte 37,42,36,39,38,41,62,17,13,60,22,30,31,9
3890 .byte 23,25,12,35,56,59,8,11,16,19,24,27,32